﻿using System.Collections.ObjectModel;
using System.Windows;
using Brjnk.GpxExplorer.Workspace;
using Brjnk.GpxExplorer.Workspace.Searching;

namespace Brjnk.GpxExplorer.UI
{
    /// <summary>
    /// Interaction logic for ImportFromClipboardWindow.xaml
    /// </summary>
    public partial class ImportFromClipboardWindow : Window
    {
        private DataModel data;
        private SearchService searchService;

        public ImportFromClipboardWindow(DataModel data, SearchService searchService)
        {
            items = new ObservableCollection<ItemFromClipboard>();
            this.data = data;
            this.searchService = searchService;
            InitializeComponent();
        }

        public void AddItem(ItemFromClipboard item)
        {
            items.Add(item);
        }

        private ObservableCollection<ItemFromClipboard> items;

        public ObservableCollection<ItemFromClipboard> Items { get { return items; } }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            foreach (var item in Items)
                item.Execute(data, searchService);
            items.Clear();
            this.Close();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            items.Clear();
            this.Close();
        }
    }
}